package com.content.Controller.artist;

import com.common.Entity.Result;
import com.content.Entity.artist.School;
import com.content.Entity.artist.SchoolFeatures;
import com.content.Entity.artist.SchoolInheritance;
import com.content.Service.artist.SchoolService;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/school")
public class SchoolController {
    @Autowired
    private SchoolService schoolService;

    @GetMapping("/getSchoolList")
    public Result getSchoolList(@RequestParam Integer pageNum,
                                @RequestParam Integer pageSize,
                                @RequestParam(required = false) String schoolName) {
        PageInfo<School> pageInfo = schoolService.getSchoolList(pageNum, pageSize, schoolName);
        return Result.success(pageInfo);

    }

    @PostMapping("/addSchool")
    public Result addSchool(@RequestBody School school) {
        schoolService.addSchool(school);
        return Result.success();
    }

    @PutMapping("/updateSchool")
    public Result updateSchool(@RequestBody School school) {
        schoolService.updateSchool(school);
        return Result.success();
    }

    @DeleteMapping("/deleteSchool/{schoolId}")
    public Result deleteSchool(@PathVariable("schoolId") String schoolId) {
        schoolService.deleteSchool(schoolId);
        return Result.success();
    }

    @GetMapping("/getSchoolFeatures/{schoolId}")
    public Result getSchoolFeatures(@PathVariable("schoolId") String schoolId) {
        List<SchoolFeatures> list = schoolService.getSchoolFeatures(schoolId);
        return Result.success(list);
    }

    @GetMapping("/getSchoolInheritance/{schoolId}")
    public Result getSchoolInheritance(@PathVariable("schoolId") String schoolId) {
        List<SchoolInheritance> list = schoolService.getSchoolInheritance(schoolId);
        return Result.success(list);
    }
}